

<h3 class="h1">
	<b>分类管理</b>
	<span class="fr"><input id="addCategory" class="bt" type="button" value="添加分类"></span>
</h3>

<div class="admin_table mb10">
      <table width="100%">
         <tr class="tr2">
            <td>标题</td>
            <td>名称</td>
            <td>排序</td>
            <td>操作</td>
         </tr>
<?php
function viewHelperShowCategorys($view, $parentId = 0, $depth = 0) {
	if (!isset($view->groups[$parentId])) return ;
	$titlePrefix = $depth > 0 ? str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $depth - 1) . '|---&nbsp;' : '';
	$depth++;
	foreach ($view->groups[$parentId] as $item) {
?>
         <tr class="tr3">
            <td class="td2"><?php echo $titlePrefix, $item['title']; ?></td>
            <td class="td2"><?php echo $item['name']; ?></td>
            <td class="td2"><?php echo $item['order_number']; ?></td>
            <td class="td2">
            	<a href="<?php echo $view->url(array('action' => 'edit', 'id' => $item['id'])); ?>">编辑</a>
            	<a class="opDel" href="<?php echo $view->url(array('action' => 'delete', 'id' => $item['id'])); ?>">删除</a>
            	<a href="<?php echo $view->url(array('action' => 'add', 'parent_id' => $item['id'])); ?>">添加子类</a>
            </td>
         </tr>
<?php
		viewHelperShowCategorys($view, $item['id'], $depth);
	}
}
viewHelperShowCategorys($this);
?>
      </table>
</div>


<script language="javascript">
$(document).ready(function() {
	$("a.opDel").click(function() {
		return confirm('是否删除该分类？');
	});
	$("#addCategory").click(function() {
		self.location.href = "<?php echo $this->url(array('action' => 'add')); ?>";
	});
});

</script>